//
//  DeviceMountedController.h
//  Podcopter
//
//  Created by Ben Gotow on 2/1/10.
//  Copyright 2010 Apple Inc. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "GamePeer.h"
#import "ThrustToBrightnessMap.h"
#import "PIDController.h"

@interface DeviceMountedController : UIViewController <UIAccelerometerDelegate, GamePeerDelegate, UIImagePickerControllerDelegate> {

    GamePeer *         connection;
    IBOutlet UILabel * remoteControlStatusLabel;

    UIAcceleration *   baseValues;
    BOOL               baseValuesSet;
    
    IBOutlet UILabel * rollValueLabel;
    IBOutlet UILabel * pitchValueLabel;
	
	IBOutlet UIView * frontSquare;
	IBOutlet UIView * backSquare;
	IBOutlet UIView * leftSquare;
	IBOutlet UIView * rightSquare;
	
	IBOutlet UIButton * startTestSequenceButton;
	IBOutlet UIButton * stopTestSequenceButton;
	IBOutlet UILabel * testSequenceStatusLabel;
	NSTimer * testSequenceTimer;
	NSTimeInterval testSequenceTime;
	
	Class<ThrustToBrightnessMap> thrustMap;
	PIDController *pitchController;
	PIDController *rollController;
    
	double devicePitch;
	double deviceRoll;
	double controllerPitch;
	double controllerRoll;
	double controllerThrust;
	NSTimeInterval lastControllerResponseTime;
	NSTimeInterval lastFPSUpdateTime;
    int framesSinceFPSUpdate;
    double fps;
    
    UIImagePickerController * imagePicker;
}

@property (nonatomic, retain) UIImagePickerController * imagePicker;

- (void)accelerometer:(UIAccelerometer *)accelerometer didAccelerate:(UIAcceleration *)acceleration;
- (IBAction)runTestSequence:(id)sender;
- (IBAction)stopTestSequence:(id)sender;
- (void)updateTestSequence:(id)sender;

- (void)updateMotorOutputs:(double)deltaTime;

@end

